package com.wanmait.movie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.movie.entity.FoodToCombo;
import com.wanmait.movie.mapper.FoodToComboMapper;
import com.wanmait.movie.service.FoodToComboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class FoodToComboServiceImpl extends ServiceImpl<FoodToComboMapper, FoodToCombo> implements FoodToComboService {
    @Resource
    private FoodToComboMapper foodToComboMapper;

    @Override
    public List<Integer> findFoodListByComboId(Integer id) {
        LambdaQueryWrapper<FoodToCombo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FoodToCombo::getComboId, id);
        List<Integer> foodToComboIdList = new ArrayList<>();
        foodToComboMapper.selectList(queryWrapper).forEach(foodToCombo->{
            foodToComboIdList.add(foodToCombo.getFoodId());
        });
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++");
        foodToComboIdList.forEach(System.out::println);
        System.out.println("++++++++++++++++++++++++++++++++++++++++++++");
        return foodToComboIdList;
    }
}
